package br.ufrj.ppgi.infovis.mtgraph;

import org.mt4j.components.MTComponent;
import org.mt4j.components.visibleComponents.shapes.MTLine;
import org.mt4j.input.gestureAction.TapAndHoldVisualizer;
import org.mt4j.input.inputProcessors.IGestureEventListener;
import org.mt4j.input.inputProcessors.MTGestureEvent;
import org.mt4j.input.inputProcessors.componentProcessors.tapAndHoldProcessor.TapAndHoldEvent;
import org.mt4j.input.inputProcessors.componentProcessors.tapAndHoldProcessor.TapAndHoldProcessor;
import org.mt4j.util.math.Vertex;

import br.ufrj.ppgi.infovis.util.UnorderedPair;

/**
 * @author Ewoud van Pareren
 * 
 * A simple edge class.
 * 
 */
public class GraphEdgeGestures {
	
	private GraphScene scene;
	private GraphEdge edge;
	private MTComponent linha;
	
	public GraphEdgeGestures(GraphScene scene, GraphEdge Edge) {
		this.scene = scene;
		this.edge = Edge;
		this.linha = Edge.getComponent();
		this.clearAllGestures(this.linha);				
	}

	//Gestures
	public void addGestures() {
		this.addTapHold();
	}
	
	//TAP&HOLD
	public void addTapHold() {
		this.linha.registerInputProcessor(new TapAndHoldProcessor(this.scene.getMTApplication(), 2000));
		this.linha.addGestureListener(TapAndHoldProcessor.class, new TapAndHoldVisualizer(this.scene.getMTApplication(), this.scene.getCanvas()));
		this.linha.addGestureListener(TapAndHoldProcessor.class, new IGestureEventListener() {
			public boolean processGestureEvent(MTGestureEvent ge) {
				TapAndHoldEvent th = (TapAndHoldEvent)ge;
				switch (th.getId()) {
				case TapAndHoldEvent.GESTURE_STARTED:
					break;
				case TapAndHoldEvent.GESTURE_UPDATED:
					break;
				case TapAndHoldEvent.GESTURE_ENDED:
					if (th.isHoldComplete()){
						TapHold();
					}
					break;
				default:
					break;
				}
				return false;
			}
		});	
	}
	
	private void clearAllGestures(MTComponent comp){
		comp.unregisterAllInputProcessors();
		comp.removeAllGestureEventListeners();
	}
	
	private void TapHold() {
		System.out.println("tap & hold");
		//Exclusao
		//this.scene.DeleteEdge(this.edge);
	}
}
